import request from '@/utils/axios'

export interface ApiErrorLogType {
  id: number
  traceId: string
  userId: number
  userType: number
  applicationName: string
  requestMethod: string
  requestParams: string
  requestUrl: string
  userIp: string
  userAgent: string
  exceptionTime: Date
  exceptionName: string
  exceptionMessage: string
  exceptionRootCauseMessage: string
  exceptionStackTrace: string
  exceptionClassName: string
  exceptionFileName: string
  exceptionMethodName: string
  exceptionLineNumber: number
  processUserId: number
  processStatus: number
  processTime: Date
  resultCode: number
  create_time: Date
}

export interface ErrorLogPageReqType extends PageParam {
  userId?: number
  userType?: number
  applicationName?: string
  processStatus?: number
  exceptionTime?: Date[]
}

/**
 * 错误日志接口
 */
export const ErrorLogApi = {
  // 日志状态修改
  updateStatus: (id: number, processStatus: number) => {
    const data = {
      id,
      processStatus
    }
    return request.put({ url: '/infra/api-error-log/update-status', data, is_mock: true })
  },
  // 查询分页列表
  page: (params: ErrorLogPageReqType) => {
    return request.get({ url: '/infra/api-error-log/page', params, is_mock: true })
  },
  // 导出日志
  export: (params: ErrorLogPageReqType) => {
    return request.get({ url: '/infra/api-error-log/export', params, is_mock: true })
  }
}
